<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <#include "../common/header.ftl">
    <script type="text/javascript">
        var info;
        $(function () {
            $(".info").click(function () {
                info = $(this).data("info")
                if(info=="one"){
                    $("#role").css("display","none")
                    var user = $(this).data("user");
                    $("#editForm input[name='user.id']").val(user.id)
                    $("#editForm input[name='name']").val(user.nickName)
                    $("#editForm select[name='ids']").val("")
                }else{
                    $("#editForm input[name='user.id']").val("")
                    $("#editForm input[name='name']").val("批量发送")
                    $("#role").css("display","")
                }
                $("#inputModal").modal('show')
            })
            $(".submitBtn").click(function () {
                $("#editForm option").prop("selected", true);
                $("#editForm").submit();
            })
        });
        function moveAll(srcEl, targetEl) {
            $("." + srcEl + " option").appendTo($("." + targetEl));
        }

        function moveSelected(srcEl, targetEl) {
            $("." + srcEl + " option:selected").appendTo($("." + targetEl));
        }

    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
    <#include "../common/top.ftl">
    <div class="row">
        <div class="col-lg-3">
            <#assign currentMenu="user" />
            <#include "../common/menu.ftl">
        </div>
        <div class="col-lg-9">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-head-line">用户管理</h1>
                </div>
            </div>
            <!--高级查询--->
            <form class="form-inline" id="searchForm" action="/user/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入昵称/邮箱">
                </div>
                <button id="btn_query" class="btn btn-info">
                    <span class="glyphicon glyphicon-search"></span> 查询
                </button>
                <a role="button" id="btn_query" class="btn btn-info info" data-info="many">
                    <span class="glyphicon glyphicon-plus"></span> 批量发送
                </a>
            </form>


            <table class="table table-striped table-hover">
                <tr>
                    <th>序号</th>
                    <th>邮箱</th>
                    <th>昵称</th>
                    <th>地区</th>
                    <th>头像</th>
                    <th>性别</th>
                    <th>签名</th>
                    <th>操作</th>
                </tr>
                <#list pageInfo.list as entity>
                    <tr>
                        <td>${entity_index + 1}</td>
                        <td>${entity.email}</td>
                        <td>${entity.nickName}</td>
                        <td>${entity.place}</td>
                        <td><img src="${entity.headImgUrl}" width="60"></td>
                        <td>${entity.genderName}</td>
                        <td>${entity.sign}</td>
                        <td>
                            <a role="button" class="btn btn-success btn-xs info" data-info="one" data-user='${entity.json}'>
                                <span class="glyphicon glyphicon-ok"></span> 发送信息
                            </a>
                        </td>
                    </tr>
                </#list>
            </table>
            <#include "../common/page.ftl">
        </div>
    </div>
</div>
<div id="inputModal" class="modal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">发送系统信息</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" action="/systemmessage/save.do" method="post" id="editForm">
                    <input type="hidden" name="user.id"/>
                    <div class="form-group" >
                        <label class="col-lg-4 control-label">用户：</label>
                        <div class="col-lg-6">
                            <input type="text" class="form-control" name="name" readonly/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-4 control-label">发送信息：</label>
                        <div class="col-lg-6">
                            <textarea class="form-control" name="content"></textarea>
                        </div>
                    </div>

                        <div class="form-group" id="role" style="display: none">
                            <div>
                                <label for="role" class="control-label" style="margin-left: 60px">所有用户：</label>
                            </div>
                            <div class="row" style="margin-top: 10px">
                                <div class="col-sm-4 col-sm-offset-1">
                                    <select multiple class="form-control allRoles" size="15">
                                    <#--   <c:forEach items="${roles}" var="r">
                                        <option value="${r.id}">${r.name}</option>
                                    </c:forEach>-->
                                        <#list users as u>
                                             <option value="${u.id}">${u.nickName}</option>
                                        </#list>
                                    </select>
                                </div>
                                <div class="col-sm-2" style="margin-top: 60px;" align="center">
                                    <div>
                                        <a type="button" class="btn btn-info " style="margin-top: 10px"
                                           onclick="moveSelected('allRoles','selfRoles')"
                                        >&nbsp;&gt;&nbsp;</a>
                                        <br>
                                        <a type="button" class="btn btn-info " style="margin-top: 10px"
                                           onclick="moveSelected('selfRoles','allRoles')"
                                        >&nbsp;&lt;&nbsp;</a>
                                        <br>
                                        <a type="button" class="btn btn-info " style="margin-top: 10px"
                                           onclick="moveAll('allRoles','selfRoles')"
                                        >&gt;&gt;</a>
                                        <br>
                                        <a type="button" class="btn btn-info " style="margin-top: 10px"
                                           onclick="moveAll('selfRoles','allRoles')"
                                        >&lt;&lt;</a>
                                    </div>
                                </div>

                                <div class="col-sm-4">
                                    <select multiple class="form-control selfRoles" size="15" name="ids">
                                    <#--      <c:forEach items="${entity.roles}" var="r">
                                        <option value="${r.id}">${r.name}</option>
                                    </c:forEach>-->
                                    </select>
                                </div>
                            </div>
                        </div>

                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary submitBtn">发送</button>
            </div>
        </div>
    </div>
</div>
</body>
</html>